home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1996
/
MacHack 1996.toast
/
Presentations
/
Presentations ’93
/
Voice Toolkit
/
Voice Sequence
< prev
next >
Wrap
Lisp/Scheme
|
1993-03-02
|
3KB
|
95 lines
(in-package "VOICE-TOOLKIT")
(export '(voice-sequence initialize-instance cell-contents table-sequence
set-table-sequence))
(defclass voice-sequence (sequence-dialog-item)
((finder :accessor finder :initform (make-hash-table :test #'equal))
(careful :accessor careful :initarg :careful :initform t)
(exclusive :accessor exclusive :initform t)))
(defmethod identify ((vs voice-sequence))
(mapcar #'identify (actual-table-sequence vs)))
(defmethod initialize-instance ((vs voice-sequence) &rest args)
(apply #'call-next-method (cons vs (make-voice-shell args)))
(setf (exclusive vs) (exclusive-p args)))
(defun exclusive-p (arglist)
(cond ((null arglist))
((equal (first arglist) :selection-type)
(equal (second arglist) :single))
(t (exclusive-p (rest arglist)))))
(defmethod make-slots ((vs voice-sequence) somelist)
(if (onscreen-p vs)
(remove-voice-items (set-diff (actual-table-sequence vs)
(existing-slots (actual-table-sequence vs)
somelist))))
(items-to-slots somelist
(existing-slots (actual-table-sequence vs)
somelist)
(mapcar #'(lambda (item)
(make-slot vs item))
(set-diff somelist (table-sequence vs)))))
(defun items-to-slots (items oldslots newslots)
(if items
(cons (first (or (member (first items) oldslots :test #'in-slot)
(member (first items) newslots :test #'in-slot)))
(items-to-slots (rest items) oldslots newslots))))
(defun make-slot (vs item)
(make-instance 'voice-slot
:text (format nil "~a" item)
:contents item
:owner vs
:careful (careful vs)))
(defmethod mark-item ((vs voice-sequence) slot)
(cell-select vs 0 slot)
(scroll-to-cell vs 0 slot))
(defmethod unmark-item ((vs voice-sequence) slot)
(cell-deselect vs 0 (find-slot vs slot)))
(defmethod cell-contents ((vs voice-sequence) h &optional v)
(contents (call-next-method vs h v)))
(defmethod find-slot ((vs voice-sequence) slot)
(gethash slot (finder vs)))
(defmethod file-sequence-items ((vs voice-sequence) newslots)
(clear-finder vs)
(file-item-order (finder vs) newslots)
newslots)
(defun file-item-order (table items &optional (count 0))
(if items
(progn
(setf (gethash (first items) table) count)
(file-item-order table (rest items) (+ count 1)))))
(defmethod clear-finder ((vs voice-sequence))
(clrhash (finder vs)))
(defmethod set-table-sequence ((vs voice-sequence) somelist)
(call-next-method vs (file-sequence-items vs (make-slots vs somelist)))
(if (onscreen-p vs) (file-voice-items (actual-table-sequence vs))))
(defmethod table-sequence ((vs voice-sequence))
(slot-values (call-next-method vs)))
(defmethod actual-table-sequence ((vs voice-sequence))
(let ((hold nil))
(maphash #'(lambda (k v)
v
(setf hold (cons k hold)))
(finder vs))
hold))